POV-Ray : Newsgroups : povray.advanced-users : triangle centers : triangle centers Server Time
29 Jul 2024 00:32:16 EDT (-0400)
  triangle centers  
From: David Wallace
Date: 8 Jul 2003 16:30:42
Message: <3f0b29f2$1@news.povray.org>
I am trying to inscribe a circle in a triangle.  Please help me debug the
macro I made to carry it out:

#macro PointLineDist(ps, po, dr)
 #local ptx = dr.z*(ps.y-po.y)-dr.y*(ps.z-po.z);
 #local pty = dr.x*(ps.z-po.z)-dr.z*(ps.x-po.x);
 #local ptz = dr.y*(ps.x-po.x)-dr.x*(ps.y-po.y);
 (vlength(<ptx,pty,ptz>) / vlength(dr))
#end

#macro InCircle(p1, p2, p3, cen, rad) // cen, rad are center and radius I
want to calculate
 // Radius calculation
 #local ln1 = vlength(p2-p1);
 #local ln2 = vlength(p3-p1);
 #local ln3 = vlength(p3-p2);
 #local hPer = (ln1+ln2+ln3)/2;
 #local area = sqrt(hPer*(hPer-ln1)*(hPer-ln2)*(hPer-ln3));
 #declare rad = 0+area/hPer;

 // InCenter calculation
 #local dr1 = vnormalize(p2-p1);
 #local dr2 = vnormalize(p3-p1);
 #local dr3 = vnormalize(p3-p2);
 #local drb1 = vnormalize(dr1+dr2); // Bisects angle through p1
 #local drb2 = vnormalize(dr3-dr1); // Bisects angle through p2
 #declare cen = p2 + drb2*PointLineDist(p2, p1, drb1);
#end

When I instantiate the macro in the following code:

#declare odfRadI=0.0;
#declare odfCenI=<0,0,0>;
InCircle(< 0.01,-0.01, 0>, < 2.85,-0.01, 0>, < 0.01,-2.85, 0>, odfRadI,
odfCenI)

#declare odfBrace = union {
 difference {
  cylinder { < 0,-3.0,-0.02>, < 0,-3.0, 0.02>, 0.05 }
  cylinder { < 0,-3.0,-0.03>, < 0,-3.0, 0.03>, 0.04 }
  plane { x, 0 }
 }
 box { < 0.00,-2.96,-0.02>, < 0.01, 0.00, 0.02> }
 box { < 0.00,-3.15,-0.02>, < 0.01,-3.04, 0.02> }
 difference {
  cylinder { < 3.0, 0.0, -0.02>, < 3.0, 0.0, 0.02>, 0.05 }
  cylinder { < 3.0, 0.0, -0.03>, < 3.0, 0.0, 0.03>, 0.04 }
  plane {-y, 0 }
 }
 difference {
  cylinder { z*-.02, z*0.02, odfRadI+.01 } // error is here
  cylinder { z*-.03, z*0.03, odfRadI }
  translate odfCenI
 }
 box { < 0.00,-0.01,-0.02>, < 2.96, 0.00, 0.02> }
 box { < 3.04,-0.01,-0.02>, < 3.15, 0.00, 0.02> }
 box {
  < 0.00,-2.86,-0.015>,< 2.85,-2.85, 0.015>
  matrix <1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0>
 }
 box {
  < 0.00,-3.15,-0.015>,< 3.15,-3.14, 0.015>
  matrix <1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0>
 }
 ObjLine( odfRing, < 1.57,-1.43, 0>, < 0.14, 0.14,0>, 10 )
 ObjLine( odfRing, < 1.43,-1.57, 0>, <-0.14,-0.14,0>, 10 )
 texture { colWLamp }
}

POV-Ray complains that odfRadI is a vector.  How did this happen?


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.